import  { roleUser } from '@/api/role';
export default {
  mounted(el, binding, vnode) {
    const { value } = binding
    const all_permission = "*:*:*";
    // 后端返回的角色按钮权限
    const permissions = roleUser
    if (value && value instanceof Array && value.length > 0) {
      // 前端定义的
      const permissionFlag = value
      const hasPermissions = permissions.some(permission => {
        return all_permission === permission || permissionFlag.includes(permission)
      })
      console.log('hasPermissions', hasPermissions);
      if (!hasPermissions) {
        el.parentNode && el.parentNode.removeChild(el)
      }
    } else {
      throw new Error(`请设置操作权限标签值`)
    }
  }
}